package com.alks.function.controller.biocontrol.deptwork;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.entity.data.enums.biocontrol.TimeCaluEnum;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.biocontrol.deptwork.TimeRequest;
import com.alks.function.service.biocontrol.deptwork.ITimeDefService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@ApiRestController("/bioDeptWrok")
@Api(value = "生控作业",tags = "生控部-生控作业-时段门槛定义")
@RequiredArgsConstructor
@RoleCheck(prgIds = {"140101","120112"})
public class TimeDefController {
    private final ITimeDefService service;

    @GetMapping("/getTimeQuery")
    @ApiOperation(value = "前推/后拉时段门槛-查询",tags = "生控部-生控作业-时段门槛定义")
    public ResponseInfo getTimeQuery(){
        return service.getTimeQuery();
    }

    @GetMapping("/getCaluQuery")
    @ApiOperation(value = "计算方法查询-查询",tags = "生控部-生控作业-时段门槛定义")
    public ResponseInfo getCaluQuery(){
        return ResponseInfo.ok(TimeCaluEnum.getTypeList());
    }

    @PutMapping("/timeUpdate")
    @ApiOperation(value = "时段门槛数据修改-更新",tags = "生控部-生控作业-时段门槛定义")
    public ResponseInfo timeUpdate(@RequestBody TimeRequest request){
        return service.timeUpdate(request);
    }


    @PutMapping("/timeDelete")
    @ApiOperation(value = "时段门槛数据删除-删除",tags = "生控部-生控作业-时段门槛定义")
    public ResponseInfo timeDelete(@RequestBody TimeRequest request){
        return service.timeDelete(request);
    }


    @PutMapping("/timeAdd")
    @ApiOperation(value = "时段门槛数据新增-新增",tags = "生控部-生控作业-时段门槛定义")
    public ResponseInfo timeAdd(@RequestBody TimeRequest request){
        return service.timeAdd(request);
    }

}
